<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<!--<![endif]-->
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>登录-后台管理系统</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <!-- Favicon -->
    <link rel="shortcut icon" href="/web_admin/img/favicon.ico" type="image/x-icon">
    <!-- Bootstrap core CSS -->
    <link rel="stylesheet" href="/web_admin/plugins/bootstrap/css/bootstrap.min.css">
    <!-- Fonts from Font Awsome -->
    <link rel="stylesheet" href="/web_admin/css/font-awesome.min.css">
    <!-- CSS Animate -->
    <link rel="stylesheet" href="/web_admin/css/animate.css">
    <!-- Custom styles for this theme -->
    <link rel="stylesheet" href="/web_admin/css/main.css">
    <!--验证码-->
    <link rel="stylesheet" href="/web_admin/plugins/code/code.css">

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="/web_admin/js/html5shiv.js"></script>
    <script src="/web_admin/js/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<section id="login-container">
    <div class="row" style=" margin-left: 0;margin-right: 0;">
        <div class="col-md-3" id="login-wrapper">
            <div class="panel panel-primary animated flipInY">
                <div class="panel-heading">
                    <h3 class="panel-title">
                        管理系统
                    </h3>
                </div>
                <div class="panel-body form-horizontal">
                    <form class="" role="form" action=""  method="post">
                        <div class="form-group">
                            <div class="col-md-12">
                                <input type="name" class="form-control" id="name" name="name" placeholder="用户名">
                                <i class="fa fa-user"></i>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-12">
                                <input type="password" class="form-control" id="password" name="pwd" placeholder="密码">
                                <i class="fa fa-lock"></i>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-12">
                                <div class="code-box" id="code-box">
                                    <input type="text" name="code" class="code-input" />
                                    <p></p>
                                    <span>>>></span>
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-md-12">
                                <input type="button" id="admin_login" class="btn btn-primary btn-block" value="登录">
                                <hr />
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</section>
<!--Global JS-->
<script src="/web_admin/js/jquery-1.10.2.min.js"></script>

<!--验证码-->
<script src="/web_admin/plugins/code/code.js"></script>
</body>
<script>
    $(document).on('click','#admin_login',function(){
        admin_login();
    });
    //回车登录
    $(document).keydown(function(event){
        if($("#password").is(":visible")){
            if (event.keyCode == "13") {
                admin_login();
            }
        }
    });
    function admin_login(){
        var name = $("input[name='name']").val();
        var password = $("input[name='pwd']").val();
        if(name==""){alert('请输入登录用户名!');return;}
        if(password==""){alert('请输入登录密码!');return;}
        $('#admin_login').val('登录中...').attr('disabled',true);;
        $.ajax({
            type:'post',
            dataType:'json',
            data:'name='+name+'&password='+password,
            url: "/admin/login",
            success:function(json){
                $('#admin_login').val('登录').attr('disabled',false);
                if(json.status==0){
                    self.location='/admin/Index/';
                }else{
                    alert(json.msg);
                }
            }
        })
    }
</script>
<script>

    window.addEventListener('load',function(){

        //code是后台传入的验证字符串
        var code = "jsaidaisd656",
                codeFn = new moveCode(code);

        //获取当前的code值
        //console.log(codeFn.getCode());

        //改变code值
        //code = '46asd546as5';
        //codeFn.setCode(code);

        //重置为初始状态
        //codeFn.resetCode();
    });
</script>
</html>